#include<iostream>
#include<unordered_set>

using namespace std;

vector<int> intersection(vector<int>& nums1, vector<int>& nums2) 
{
    unordered_set<int> result;
    unordered_set<int> nums2_set(nums2.begin(),nums2.end());
    for(int cur:nums1)
        if(nums2_set.find(cur)!=nums2_set.end())//find如果找到返回那个元素的指针，没找到返回end
            result.insert(cur);
    return vector<int>(result.begin(),result.end());
    
}

int main()
{
    vector<int> a={1,3,5,7,9};
    vector<int> b={3,5,7,10};
    for(int it:intersection(a,b))
    {
        cout<<it<<" ";
    }
}